package com.apobates.jforum.grief.aurl.selector;

import com.apobates.jforum.grief.aurl.core.AUrlMeta;
import java.util.Collection;
import java.util.List;
/**
 * 文件选择器
 */
public class FileSelector extends AUrlMetaGeneralSelector{
    public FileSelector(AUrlMeta rawMeta) {
        super(rawMeta);
    }

    @Override
    public Collection<String> getResult() {
        final AUrlMeta meta = getRawMeta();

        if(!meta.isLegalURL()){ // 要是一个相对路径呢?
            return List.of("/");
        }
        String temp = String.format("%s://%s", meta.getScheme(), meta.getHost());
        final String tv = (isAppendPort(meta.getPort()))? temp + ":" + meta.getPort() : temp;
        String data = meta.toString().replace(tv, "");
        return List.of(data);
    }
}
